package cn.johnyu.service.impl;

import cn.johnyu.service.WorkService;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

@Service
public class WorkServiceImpl implements WorkService {
//  此处定义资源名称和blocked处理
    @SentinelResource(value = "work",blockHandler = "workFallback")
    @Override
    public String work() {
        System.out.println("working....");
        return "working1...";
    }
//    blockHandler 方法最后一个参数追加指定异常类型
    public String workFallback(BlockException blockException){
        System.out.println("blocked....");
        return "blocked....";
    }
}
